<template>
  <el-dialog
    title="统计维度配置"
    :visible.sync="dialogVisible"
    width="600px"
    @closed="dialogClosed"
  >
    <el-transfer
      v-model="selectIds"
      :data="dimensionalityListAll"
      :titles="['隐藏选项', '显示选项']"
      filterable
      filter-placeholder="请输入关键字">
    </el-transfer>
    <div slot="footer">
      <el-button type="warning" @click.stop="openDefault">恢复至默认聚合条件</el-button>
      <el-button @click="dialogClosed">取消</el-button>
      <el-button type="primary" @click="confirm()">确定</el-button>
    </div>
  </el-dialog>
</template>


<script>
import {cloneDeep} from 'lodash';

export default {
  name: 'PolymerizeTransfer',
  props: {},
  data() {
    return {
      dialogVisible: false,
      logType: null,
      wayType: null,
      tabIndex: null,
      dimensionalityListAll: [],
      selectIds: [],
    }
  },
  methods: {
    initDialog(logType, wayType, data, tabIndex) {
      this.dialogVisible = true;
      this.logType = logType;
      this.wayType = wayType;
      this.tabIndex = tabIndex;
      this.dimensionalityListAll = cloneDeep(data);
      for (const item of data){
        if(item.isView) {
          this.selectIds.push(item.key);
        }
      }
    },
    dialogClosed(){
      this.dialogVisible = false;
      this.selectIds = [];
    },
    confirm(){
      console.log(this.selectIds);
      this.$emit('dimensionalityConfirm', cloneDeep(this.selectIds), this.tabIndex);
      this.dialogClosed();
    },
    openDefault(){
      const that = this;
      this.$confirm('确认恢复至默认统计维度, 是否继续?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        that.setDefaultData();
      })
    },
    // 恢复到默认条件
    setDefaultData(){
    }
  }
}
</script>

<style scoped lang="scss">

</style>
